package com.example.userlogindemo.entity;

import com.example.userlogindemo.assist.LoginForm;
import com.example.userlogindemo.assist.ChangeInfo;
import com.example.userlogindemo.assist.RegisterFrom;
import lombok.Data;

import javax.persistence.Entity;
import javax.persistence.Id;

@Entity
@Data
public class Userdata {
    @Id
    private String username;
    private String password;
    private String telephoneNumber;
    private String nickname;
    private String sex;
    private String city;
    private String registerTime;
    private Integer loginState;

    public Userdata() {

    }
    public Userdata(RegisterFrom registerFrom){
        username = registerFrom.getUsername();
        password = registerFrom.getPassword();
        telephoneNumber = registerFrom.getTelephoneNumber();
        nickname = registerFrom.getNickname();
        registerTime = registerFrom.getRegisterTime();
    }

    public Userdata(LoginForm loginForm){
        username = loginForm.getUsername();
        password = loginForm.getPassword();
    }

    public Userdata(ChangeInfo changeInfo) {
        username = changeInfo.getUsername();
        password = changeInfo.getPassword();
        telephoneNumber = changeInfo.getTelephoneNumber();
        nickname = changeInfo.getNickname();
        sex = changeInfo.getSex();
        city = changeInfo.getCity();
    }

    public void ModifyByChangeInfo(ChangeInfo changeInfo){
        username = changeInfo.getUsername();
        password = changeInfo.getPassword();
        telephoneNumber = changeInfo.getTelephoneNumber();
        nickname = changeInfo.getNickname();
        sex = changeInfo.getSex();
        city = changeInfo.getCity();
    }
}
